package com.smart.manager.pop.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.smart.common.entities.ajax.AjaxResult;
import com.smart.common.entities.constant.SmartConstant;
import com.smart.common.entities.core.Page;
import com.smart.manager.pop.entities.body.RActivityRecord;
import com.smart.manager.pop.entities.body.RDisBill;
import com.smart.manager.pop.entities.models.PopDisBill;
import com.smart.manager.pop.entities.models.PopDisRecord;
import com.smart.manager.pop.repository.DisBillRepository;
import com.smart.manager.pop.repository.DisRecordRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author Administrator
 */

@Api(tags = "台账流水")
@RestController
@RequestMapping(SmartConstant.MANAGER_API_PREFIX + "pop/dis")
@RequiredArgsConstructor
public class DisRecordApi {

    private final DisBillRepository billRepository;
    private final DisRecordRepository disRecordRepository;
    
    @GetMapping(value = "bill/pageList")
    @ApiOperation(value = "查询B2C台账")
    @SaCheckPermission("pop:dis:bill:pageList")
    public AjaxResult<Page<PopDisBill>> pageList(@Validated RDisBill.SearchBody body) {
        Page<PopDisBill> result = billRepository.pageList(body);
        return AjaxResult.data(result);
    }



    @GetMapping(value = "record/pageList")
    @ApiOperation(value = "查询B2C邀请记录")
    @SaCheckPermission("pop:dis:record:pageList")
    public AjaxResult<Page<PopDisRecord>> getRecordPage(@Validated  RActivityRecord.SearchBody search  ) {
        Page<PopDisRecord> result = disRecordRepository.pageList(search);
        return AjaxResult.data(result);
    }

}
